package my.edu.model.bills.sales.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import my.edu.common.myInterface.AccountCount;
import my.edu.common.myInterface.CanAudit;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@TableName("sales_order")
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知字段
public class SalesOrder implements CanAudit, AccountCount, Serializable {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String orderNo;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate orderDate;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate deliveryDate;
    private String customerAddress;
    private String customerName;
    private BigDecimal discountRate;//优惠率
    private BigDecimal salesAmount;
    private BigDecimal discountAmount;//收款优惠
    private BigDecimal amountAfterDiscount;//优惠后金额
    //private BigDecimal customerBearExpense;//客户承担费用
    private BigDecimal receivedAmount;//已收款金额
    private String collectionStatus;//收款状态
    private String refundStatus;//退款状态
    //private String orderStatus;//对单状态
    private String accountingStatus;//对账状态
    private Integer isAudited;//
    private BigDecimal debt;//欠款
    private BigDecimal salesExpense;//销售费用
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate collectionArrivalDate;//收款到账日期
    private String paymentChannel;//支付通道
    private String deliveryMethod;//交货方式
    private String paymentTerms;//收款条件
    private Integer quantity;
    private String remark;//备注
    private Long prepaymentOrderId;//预收款单ID
    private String prepaymentOrderNo;//预收款单编号
    private BigDecimal prepaymentAmount;//预收款金额
    private Long routeId;//线路ID
    private String routeName;//
    private Long settlementAccountId;//结算账户ID
    private String settlementAccountName;//
    private Long salesReturnOrderId;//销货退货单ID
    private String salesReturnOrderNo;//
    private Long customerId;//客户ID
    private String customerCategory;//客户类别
    @TableField(update = "")
    private Long salespersonId;//销售人员ID
    @TableField(update = "")
    private String salespersonName;//
    private Long auditorId;//审核人ID
    private String auditorName;
    private String logisticsCompany;
    private Long logisticsId;//物流单ID
    private String logisticsNo;
    @TableField(fill = FieldFill.INSERT)
    private Long createdBy;
    @TableField(fill = FieldFill.INSERT)
    private String createdName;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;
    @TableField(fill = FieldFill.UPDATE)
    private String updateName;
    @Version
    private Integer version;

    @Override
    public BigDecimal getCirculatingMoney() {
        return receivedAmount;
    }
}